package cn.migu.music.hangupsms.schedule;

import cn.migu.music.hangupsms.common.config.SftpHostConfig;
import cn.migu.music.hangupsms.service.sftp.BlackUserExportSftpService;
import cn.migu.music.schedule.ScheduleJobExecutor;
import cn.migu.music.schedule.api.mq.JobExecuteNotify;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.ArrayUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * 增量黑名单上传SFTP
 */
@Service("addBlackUserUpSftpJob")
@Slf4j
public class AddBlackUserUpSftpJob implements ScheduleJobExecutor {

    @Autowired
    private BlackUserExportSftpService blackUserExportSftpService;
    @Autowired
    private SftpHostConfig             sftpHostConfig;

    @Override
    public void execute(JobExecuteNotify jobExecuteNotify) {
        String localIdSupport = sftpHostConfig.getLocalIdFilter();
        String[] localIdArr = StringUtils.split(localIdSupport, "|");
        if (ArrayUtils.isNotEmpty(localIdArr)) {
            for (String localId : localIdArr) {
                // 增量导出
                blackUserExportSftpService.exportBlackUser(localId, BlackUserExportSftpService.EXPORT_TYPE_ADD, null, null);
            }
        }

    }
}
